<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>教导读书会</title>

    <script type="text/javascript" src="{{asset('js/jquery.min.js?dd')}}"></script>
    <script type="text/javascript" src="{{asset('js/js.js?dd')}}"></script>
    <script type="text/javascript" src="{{asset('js/weblogin.js?ddd')}}"></script>

    <link rel="stylesheet" href="/css/common.css">
    <link rel="stylesheet" href="/css/weblogin/login.css">
</head>
<body>

    <div class="container buy-page">
        <div class="topinfo">
            <p class="headimg">
                <img src="{{$headImg}}">
            </p>
            <p>
                <span>{{$userName}}</span>
                <span>这一年，投资自己{{$money}}元</span>
            </p>
        </div>

        <div class="pay-btn" onclick="wxpay()">投资自己</div>
        <p class="notice">下载APP微信登录,客服微信：laohoulundao</p>

        <div class="description" style="margin-bottom:20px;">
            <title>会员权益</title>
            <div>
                <h3>一、有效时间</h3>
                <p>{{$time}}</p>
                <h3>二、老侯代读</h3>
                <p>每年50本优质书籍代读，图文、音频、视频讲解（非电子数原著）</p>
                <h3>三、商业课题分享</h3>
                <p>每年100个商业课题视频分享</p>
                <h3>四、学习365</h3>
                <p>每年365条经营智慧分享</p>
                <h3>五、资源共享</h3>
                <p>会员期间平台所有资源免费学习</p>
                @if($vipType == 2)
                <h3>六、超值大礼</h3>
                <p>参与线下课程推广，详情咨询客服</p>
                @endif
            </div>
        </div>
    </div>
</body>
</html>

<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>

    var order   = {
        orderNumber:"{{$orderNumber}}",
        vipType:"{{$vipType}}",
        _token:"{{csrf_token()}}",
        openId:"{{$openId}}"
    };

    function wxpay()
    {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {!! $payConfig !!},
            function(res){
                if(res.err_msg == "get_brand_wcpay_request:ok" )
                {
                    add_order();
                }
            }
        );


    }


    function add_order()
    {
        var url = "/web/weblogin/add_buy_vip_order";
        $.ajax({
            url:url,
            type:'post',
            data:order
        }).success(function(){

            alert("购买成功");
            setTimeout(function(){
                location.href = "/downloadpage.html";
            },1000);
        })
    }




</script>